package com.cltech.mapper;

import com.cltech.dto.SysUserDto;
import com.cltech.entity.sys.SysUser;
import org.mapstruct.*;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * Created by Administrator on 2019/4/9.
 */
@Mapper(componentModel = "spring")
public interface SysUserMapper {
    @Mappings({
            @Mapping(source = "organizationId", target = "organization.id"),
            @Mapping(source = "organizationName", target = "organization.name"),
            @Mapping(source = "organizationCode", target = "organization.code")
    })
    SysUser dtoToEntity(SysUserDto sysUserDto);
    @InheritConfiguration
    List<SysUser> dtoToEntity(List<SysUserDto> sysUserDto);
    @InheritInverseConfiguration
    SysUserDto entityToDto(SysUser sysUser);
    @InheritInverseConfiguration
    List<SysUserDto> entityToDto(List<SysUser> sysUser);
    default Page<SysUserDto> entityToDto(Page<SysUser> page){
        return page.map(this::entityToDto);
    }
}